package com.parkwalk.xxx.component;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;

public abstract class AbstractPanelWithMouseEvent extends JPanel {

	private static final long serialVersionUID = -1349877070460309454L;
	protected boolean isMouseEntered;

	public AbstractPanelWithMouseEvent() {
		this.addMouseListener(new ComponentMouseListenr(this));
	}

	public void mouseClicked(MouseEvent e) {

	}

	public void mouseEntered(MouseEvent e) {

	}

	public void mouseExited(MouseEvent e) {

	}

	public void mousePressed(MouseEvent e) {

	}

	public void mouseReleased(MouseEvent e) {

	}

}

class ComponentMouseListenr implements MouseListener {
	private AbstractPanelWithMouseEvent pb;

	public ComponentMouseListenr(AbstractPanelWithMouseEvent pb) {
		this.pb = pb;
	}

	public void mouseClicked(MouseEvent e) {
		System.out.println("mouse click.");
		pb.mouseClicked(e);
		pb.updateUI();
	}

	public void mouseEntered(MouseEvent e) {
		System.out.println("mouse entered.");
		pb.mouseEntered(e);
		pb.isMouseEntered = true;
		pb.updateUI();
	}

	public void mouseExited(MouseEvent e) {
		System.out.println("mouse exited.");
		pb.mouseExited(e);
		pb.isMouseEntered = false;
		pb.updateUI();
	}

	public void mousePressed(MouseEvent e) {
		System.out.println("mouse presesed.");
		pb.mousePressed(e);
		pb.updateUI();
	}

	public void mouseReleased(MouseEvent e) {
		System.out.println("mouse released.");
		pb.mouseReleased(e);
		pb.updateUI();
	}

}